#include "open_count.h"
#include "imu_driver.h"
#include "motor_driver.h"
#include "beep_driver.h"
struct open_count_type_S open_count;

float danbianqiaozhongjuli = 2.2;
float tiaoyuejuli = 0.20;
int kanyuan = 82;
int tiaoyuedian = 40;
int danbianqiaosudu = 400;


void open_count_start(struct open_count_S *self)

{
    if (self->state == end)
    {
        self->state = start;
    }    
}

void open_count_end(struct open_count_S *self)

{
    if (self->state == start)
    {
        self->state = end;
    }     
}

void open_count_loop(struct open_count_S *self, float delta)

{
    if (self->state == start)
    {
        self->num += delta;

    } 
    else if (self->state == end)
    {
        self->num = 0;

    }  
}

void open_count_loop_all(struct open_count_type_S *self)

{
   open_count_loop(&self->angle,imu_0.gz*0.005);
   open_count_loop(&self->distance,motor.real_delta_m);
   open_count_loop(&self->time,1);
}


void open_count_init(struct open_count_S *self)

{
    self ->num = 0;
    self->state = end;
}

void open_count_all_init(struct open_count_type_S *self)
{
           open_count_init(&self->angle);
           open_count_init(&self->distance);
           open_count_init(&self->time);
           self->step_flag = 0;
           self->banma_flag = 0;
           self->ok_long = 0;
}
